package com.rc.saas.mini.service.ticket;

import com.rc.saas.mini.common.constant.WebConstant;
import com.rc.saas.mini.mapper.ticket.TenantTicketTypeMapper;
import com.rc.saas.mini.model.tenant.TenantTicketType;
import com.rc.saas.mini.model.tenant.TenantTicketTypeExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/4/30
 */
@Service
public class TenantTicketTypeServiceImpl implements TenantTicketTypeService {
    @Autowired
    private TenantTicketTypeMapper tenantTicketTypeMapper;

    @Override
    public TenantTicketTypeMapper getMapper() {
        return tenantTicketTypeMapper;
    }

    @Override
    public TenantTicketType selectUsedTicket(Long ticketTypeId) {
        TenantTicketTypeExample example = new TenantTicketTypeExample();
        example.createCriteria().andStatusEqualTo(WebConstant.CON0).andTicketTypeIdEqualTo(ticketTypeId);
        return tenantTicketTypeMapper.selectByExample(example).stream().findFirst().orElseGet(() -> null);
    }

    @Override
    public List<TenantTicketType> listByMemberGet(Long memberId) {
        return tenantTicketTypeMapper.listByMemberGet(memberId);
    }
}
